package activity.setting;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.hichip.campro.R;
import base.HiActivity;
import butterknife.BindView;
import common.TitleView;

public class AlarmSnapNumActivity extends HiActivity implements View.OnClickListener {
    @BindView(R.id.title) TitleView title;
    @BindView(R.id.rl_one) RelativeLayout   rl_one;
    @BindView(R.id.rl_two) RelativeLayout   rl_two;
    @BindView(R.id.rl_there) RelativeLayout rl_there;
    @BindView(R.id.iv_one) ImageView iv_one;
    @BindView(R.id.iv_two) ImageView iv_two;
    @BindView(R.id.iv_there) ImageView iv_there;

    private int mNum=0;


    @Override
    protected int setLayoutId() {
        return R.layout.activity_alarm_snap_num;
    }

    @Override
    protected void init(@Nullable Bundle savedInstanceState) {
        getIntentData();
        initViewAndData();
        setListeners();
    }

    private void getIntentData() {
        mNum=getIntent().getIntExtra("num",0);
    }

    private void setListeners() {
        rl_one.setOnClickListener(this);
        rl_two.setOnClickListener(this);
        rl_there.setOnClickListener(this);
    }

    private void initViewAndData() {
        title.setTitle(getString(R.string.photo_num));
        title.setButton(TitleView.NAVIGATION_BUTTON_LEFT);
        title.setNavigationBarButtonListener(new TitleView.NavigationBarButtonListener() {
            @Override
            public void OnNavigationButtonClick(int which) {
                switch (which) {
                    case TitleView.NAVIGATION_BUTTON_LEFT:
                        finish();
                        break;
                }
            }
        });
        if(mNum==1){
            iv_one.setVisibility(View.VISIBLE);
            iv_two.setVisibility(View.GONE);
            iv_there.setVisibility(View.GONE);
        }else if(mNum==2){
            iv_one.setVisibility(View.GONE);
            iv_two.setVisibility(View.VISIBLE);
            iv_there.setVisibility(View.GONE);
        }else if(mNum==3){
            iv_one.setVisibility(View.GONE);
            iv_two.setVisibility(View.GONE);
            iv_there.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.rl_one:
                Intent data=new Intent();
                data.putExtra("num",1);
                setResult(Activity.RESULT_OK,data);
                finish();
                break;
            case R.id.rl_two:
                data=new Intent();
                data.putExtra("num",2);
                setResult(Activity.RESULT_OK,data);
                finish();
                break;
            case R.id.rl_there:
                data=new Intent();
                data.putExtra("num",3);
                setResult(Activity.RESULT_OK,data);
                finish();
                break;

        }
    }
}
